package com.javaweb.admin.service.impl;

import com.javaweb.admin.entity.KdlInventory;
import com.javaweb.admin.entity.KdlInventoryDay;
import com.javaweb.admin.mapper.KdlInventoryDayMapper;
import com.javaweb.admin.mapper.KdlInventoryMapper;
import com.javaweb.admin.service.KdlInventoryService;
import com.javaweb.common.config.DataSourceType;
import com.javaweb.common.config.SpecifyDataSource;
import com.javaweb.common.utils.DateUtils;
import com.javaweb.common.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.TimeUnit;

@Service
public class KdlInventoryServiceImpl implements KdlInventoryService {
    @Autowired
    private KdlInventoryDayMapper kdlInventoryDayMapper;
    @Autowired
    private KdlInventoryMapper kdlInventoryMapper;
    @Override
    @SpecifyDataSource(value = DataSourceType.SINESYS)
    public JsonResult transferData() {
        try {
            List<KdlInventoryDay> kdlInventoryDays = kdlInventoryMapper.getList();
            for (KdlInventoryDay kdlInventoryDay : kdlInventoryDays) {
                kdlInventoryDay.setSyncDay(DateUtils.getDate());
                kdlInventoryDayMapper.insert(kdlInventoryDay);
            }


            return JsonResult.success();
        } catch (Exception ex)
        {
            return JsonResult.error(ex.getMessage());
        }

    }
}
